/*
 * Filename MqttServiceImpl.java 2022年04月19日
 * Copyright © Ehome Co.Ltd. All Rgiths Reserved.
 * @author wuyingchao
 */
package com.ehome.poct.base.sys.service;

import com.ehome.poct.base.api.dto.sys.MqttInfoDTO;
import com.ehome.poct.base.api.virtual.sys.MqttInfoService;
import com.ehome.poct.base.mqtt.MqttGateway;
import com.ehome.poct.base.mqtt.MqttProperties;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author wyc
 * @since 2022/04/19 15:00
 **/
@Service
@AllArgsConstructor
public class MqttServiceImpl implements MqttInfoService {
    private final MqttProperties properties;
    private final MqttGateway mqttGateway;

    @Override
    public MqttInfoDTO get() {
        return new MqttInfoDTO(properties.getUsername(), properties.getPassword(), properties.getUrl());
    }

    @Override
    public void sendToMqtt(String data, String topic) {
        mqttGateway.sendToMqtt(data,topic);
    }
}